<?php

class MyHello {
    private $str = 'Hello, World.';
    public function get () {
        return $this->str;
    }
}

interface iMyHelloExt {
    public function __toString();
}

class MyHelloExt extends MyHello implements iMyHelloExt {
    public function __toString() {
        return $this->get ();
    }
}

function getMyHello (MyHello $obj) {
    return sprintf ('%s: %s', get_class ($obj), $obj->get ());
}

function printMyHello (iMyHelloExt $obj) {
    echo get_class ($obj), ': ', $obj, "\n";
}

class MyHelloDecorator {
    private $obj;
    public function __construct(MyHelloExt $obj) {
        $this->obj = $obj;
    }
    public function __toString() {
        return sprintf ('%s: %s', get_class ($this->obj), $this->obj);
    }
}

?>
